package Request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Map;
import java.util.Set;

@WebServlet("/requestDemo7")
public class requestDemo7 extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置流的编码
        req.setCharacterEncoding("utf-8");

        //根据参数名称获取参数值
        String username = req.getParameter("username");
        System.out.println(username);


    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //get 获取参数

        //根据参数名称获取参数值
//        String username = req.getParameter("username");
//        System.out.println("get: "+username);

        doPost(req,resp);
    }
}
